<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<%@ page import="java.util.*,util.*,dal.*,model.*,bll.*"%>
<%
	PurchaseModel obj;
	Object temp = request.getAttribute("purchase");
	if (temp != null) {
		try {
			obj = (PurchaseModel) temp;
		} catch (Exception ex) {
			obj = new PurchaseModel();
		}
	} else {
		obj = new PurchaseModel();
	}
// 	int idEvent=obj.getIdEvent();
// 	String eventName=CacheUtil.getEventName(idEvent);
// 	int idQuotation=obj.getIdQuotation();
// 	String quotationName=CacheUtil.getQuotationName(idQuotation);
// 	int idChecklist=obj.getIdChecklist();
// 	String checklistName=CacheUtil.getChecklistName(idChecklist);
// 	int idTask=obj.getIdTask();
// 	String taskName=CacheUtil.getChecklistItemName(idTask);
// 	int idQuotationItem=obj.getIdQuotationItem();
// 	String quotationItemName=CacheUtil.getQuotationItemName(idQuotationItem);
%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>View Purchase</title>
<link rel="stylesheet" href="css/common.css" />
<link rel="stylesheet" href="css/inputForm.css" />
<link rel="stylesheet" href="css/listForm.css" />
<link rel="stylesheet" href="css/jquery-ui-1.8.14.custom.css" type="text/css" />
<link rel="stylesheet" href="css/hyjack.css" type="text/css" />
<link rel="stylesheet" href="css/datepicker.css" type="text/css" />
<link rel="stylesheet" href="css/themes/ui-lightness/jquery.ui.all.css" />
<link rel="stylesheet" href="css/jquery-ui-timepicker.css" type="text/css" />
<link rel="stylesheet" href="css/jquery-datepicker.css" />
<link rel="stylesheet" href="css/jquery-dialog.css" />

<script language="javascript" type="text/javascript" src="js/jquery.min.js"></script>
<script language="javascript" type="text/javascript" src="js/jquery.hyjack.select.js"></script>
<script language="javascript" type="text/javascript" src="js/jquery.ui.core.min.js"></script>
<script language="javascript" type="text/javascript" src="js/jquery.ui.widget.min.js"></script>
<script language="javascript" type="text/javascript" src="js/jquery.ui.timepicker.js"></script>
<script language="javascript" type="text/javascript" src="js/jquery.ui.datepicker.js"></script>
<script language="javascript" type="text/javascript" src="js/datepicker.js"></script>
<script language="javascript" type="text/javascript" src="js/jquery.hyjack.js"></script>
<script language="javascript" type="text/javascript" src="js/ajaxQuickInsert.js"></script>
<script language="javascript" type="text/javascript" src="js/jquery.numeric.js"></script>
<script language="javascript" type="text/javascript" src="js/jquery.ui.tools.min.js"></script>
<script language="javascript" type="text/javascript" src="js/common.js"></script>
<script type="text/javascript" src="js/jquery-ui-1.8.14.custom.min.js"></script>
<script type="text/javascript" src="js/jquery-ui-timepicker-addon.js"></script>


<script language="javascript" type="text/javascript">
$(document).ready(pageLoaded);

function pageLoaded()
{
	//turnOnNumbericInput();
	initTooltip();	
	//initDateTimePicker();
	//initDatePicker();
	
} 

// var requiredInputs = [['name','name_required']];
// var intInputs = [];
// var doubleInputs = [];
// var dateInputs = [['payment_date_date', 'payment_date_date_invalid']];
// var timeInputs = [['order_time_date','order_time_date_invalid'],['plan_delivery_time_date','plan_delivery_time_date_invalid'],['real_delivery_time_date','real_delivery_time_date_invalid']];

// function checkInputs() {
// 	var valid = true;

// 	if (checkRequiredInputs(requiredInputs) == false) {
// 		valid = false;
// 	}
// 	if (checkIntInputs(intInputs) == false) {
// 		valid = false;
// 	}
// 	if (checkDoubleInputs(doubleInputs) == false) {
// 		valid = false;
// 	}
// 	if (checkDateInputsForCorrectedFormatOnly(dateInputs, dateFormat) == false) {
// 		valid = false;
// 	}	
// 	if (checkTimeInputsForCorrectFormatOnly(timeInputs) == false) {
// 		valid = false;
// 	}

	

// 	return valid;
// }
// function serializeProject()
// {
// 	getCascadeDropdowList('#id_project','#id_event','event');
// 	getCascadeDropdowList('#id_project','#id_checklist','checklist');
// 	getCascadeDropdowList('#id_project','#id_quotation','quotation');
// 	serializeChecklist();
// 	serializeQuotation();
	
// }
// function serializeQuotation()
// {
// 	getCascadeDropdowList('#id_quotation','#id_quotation_item','quotationItem');
// }
// function serializeChecklist()
// {
// 	getCascadeDropdowList('#id_checklist','#id_task','checklistItem');
// }
</script>
</head>
<body>
	<div class="divContainer">
		<%@ include file="menu.jsp"%>
				<form id="inputForm" action="" >
					<table class="tblInput">
						<tr>
							<td class="inputHeader">VIEW PURCHASE INFO</td>
						</tr>
							<tr>
					<td style="padding-left: 200px; padding-right: 200px;">
						<table cellspacing="0px">
						<tr class="trField">
							<td class="tdFieldName">Id</td>
							<td class="tdFieldInput">
								<input class="inputInt readonly" type="text" id="id" name="id" readonly="readonly" value="<%=obj.getId()%>" title="Id of this purchase."/>
								
							</td>
							<td class="tdErrMsg"></td>
							<td rowspan="11"></td>
							<td class="tdFieldName">Purchase Cost</td>
							<td class="tdFieldInput">
								<input class="inputNumeric" type="text" readonly="readonly" id="purchase_cost" name="purchase_cost" value="<%=obj.getPurchaseCostToString() %>" title="Purchase cost of the purchase. <br/>Note: Sum Item price - Discount + Additional cost." maxlength="20" />
							</td>
							<td class="tdErrMsg">
							</td>
							
						</tr>
						<tr class="trField">
							<td class="tdFieldName">Name</td>
							<td class="tdFieldInput">
								<input class="inputText" type="text" readonly="readonly" id="name" name="name" maxlength="255" title="Name of new purchase." value="<%=obj.getNameToString() %>" />
							</td>
							<td class="tdErrMsg">
								
							</td>
							<td class="tdFieldName">Payment Date</td>
							<td class="tdFieldInput">
								<input type="text" readonly="readonly" maxlength="10" class="inputDate" id="payment_date_date" name="payment_date_date" 
									value="<%=StringUtil.toDateString(obj.getPaymentDate())%>" title="Payment date." />
							</td>
							<td class="tdErrMsg">
								
							</td>
							
						</tr>
						<tr class="trField">
							<td class="tdFieldName">Code</td>
							<td class="tdFieldInput">
								<input class="inputText" type="text" readonly="readonly" id="code" name="code" maxlength="20" value="<%=obj.getCodeToString() %>" title="Code of the purchase." />
							</td>
							<td class="tdErrMsg">
							</td>
							<td class="tdFieldName">Order Time</td>
							<td class="tdFieldInput"><input type="text" maxlength="19" readonly="readonly" class="inputDateTime" id="order_time_date" name="order_time_date" value="<%=StringUtil.toVisualDateTimeString(obj.getOrderTime())%>" title="Order time." /> 
							</td>
							<td class="tdErrMsg">
								
							</td>
							
						</tr>
						<tr class="trField">
							<td class="tdFieldName">Description</td>
							<td class="tdFieldInput">
								<textarea id="description" name="description" readonly="readonly" rows="5" class="inputTextarea" title="Description for the purchase."><%=obj.getDescriptionToString() %></textarea>
							</td>
							<td class="tdErrMsg">
							</td>
							<td class="tdFieldName">Plan Delivery Time</td>
							<td class="tdFieldInput"><input type="text" maxlength="19" class="inputDateTime" readonly="readonly" id="plan_delivery_time_date" name="plan_delivery_time_date" value="<%=StringUtil.toVisualDateTimeString(obj.getPlanDeliveryTime())%>" title="Plan delivery time."  /> 
							</td>
							<td class="tdErrMsg">
								
							</td>
							
						</tr>
						<tr class="trField">
							<td class="tdFieldName">Remark</td>
							<td class="tdFieldInput">
								<textarea id="remark" name="remark" rows="5" readonly="readonly" class="inputTextarea" title="remark for the purchase."><%=obj.getRemarkToString() %></textarea>
							</td>
							<td class="tdErrMsg">
							</td>
							<td class="tdFieldName">Real Delivery Time</td>
							<td class="tdFieldInput"><input type="text" maxlength="19" readonly="readonly" class="inputDateTime" id="real_delivery_time_date" name="real_delivery_time_date" value="<%=StringUtil.toVisualDateTimeString(obj.getRealDeliveryTime())%>" title="Real delivery time." /> 
							</td>
							<td class="tdErrMsg">
								
							</td>
							
						</tr>
						<tr class="trField">
							<td class="tdFieldName">Status</td>
							<td class="tdFieldInput">
								<input class="inputText" readonly="readonly" title="Status of this purchase." type="text" value="<%=StringUtil.getPurchaseStatus(obj.getStatus())%>"  maxlength="255" />
							</td>
							<td class="tdErrMsg"></td>
							<td class="tdFieldName">Project</td>
							<td class="tdFieldInput">
								<input class="inputText" readonly="readonly" title="Project of this purchase." type="text" value="<%=CacheUtil.getProjectName(obj.getIdProject()) %>"  maxlength="255" />							
							</td>
							<td class="tdErrMsg">
							</td>	
							
							
						</tr>
						<tr class="trField">
							<td class="tdFieldName">Purchaser</td>
							<td class="tdFieldInput">
								<input class="inputText" readonly="readonly" title="Purchaser." type="text" value="<%=CacheUtil.getEmployeeName(obj.getPurchaser()) %>"  maxlength="255" />							
							</td>
							<td class="tdErrMsg">
							</td>	
							
							<td class="tdFieldName">Event</td>
							<td class="tdFieldInput">
								<input class="inputText" readonly="readonly" title="Event of this purchase." type="text" value="<%=CacheUtil.getEventName(obj.getIdEvent()) %>"  maxlength="255" />							
							</td>
							<td class="tdErrMsg">
							</td>		
							
							
						</tr>
						<tr class="trField">
							<td class="tdFieldName">Supplier</td>
							<td class="tdFieldInput">
								<input class="inputText" readonly="readonly" title="Supplier of this purchase." type="text" value="<%=CacheUtil.getCompanyName(obj.getSupplier()) %>"  maxlength="255" />							
							</td>
							<td class="tdErrMsg">
							</td>	
							
							<td class="tdFieldName">Checklist</td>
							<td class="tdFieldInput">
								<input class="inputText" readonly="readonly" title="Checklist of this purchase." type="text" value="<%=CacheUtil.getChecklistName(obj.getIdChecklist()) %>"  maxlength="255" />							
							</td>
							<td class="tdErrMsg">
							</td>
							
														
						</tr>
						<tr class="trField">
							<td class="tdFieldName">Currency</td>
							<td class="tdFieldInput">
								<input class="inputText" readonly="readonly" title="Currency of this purchase." type="text" value="<%=CacheUtil.getCurrencyName(obj.getIdCurrency()) %>"  maxlength="255" />							
							</td>
							<td class="tdErrMsg">
							</td>
							
							<td class="tdFieldName">Task</td>
							<td class="tdFieldInput">
								<input class="inputText" readonly="readonly" title="Task of this purchase." type="text" value="<%=CacheUtil.getChecklistItemName(obj.getIdTask()) %>"  maxlength="255" />							
							</td>
							<td class="tdErrMsg">
							</td>
																					
						</tr>
						<tr class="trField">
							<td class="tdFieldName">Additional Cost</td>
							<td class="tdFieldInput">
								<input class="inputNumeric" type="text" readonly="readonly" id="additional_cost" name="additional_cost" value="<%=obj.getAdditionalCostToString() %>" title="Additional cost of the purchase."  />
							</td>
							<td class="tdErrMsg">
							</td>
							<td class="tdFieldName">Quotation</td>
							<td class="tdFieldInput">
								<input class="inputText" readonly="readonly" title="Quotation of this purchase." type="text" value="<%=CacheUtil.getQuotationName(obj.getIdQuotation()) %>"  maxlength="255" />							
							</td>
							<td class="tdErrMsg">
							</td>
												
							
						</tr>
						<tr>
							<td class="tdFieldName">Discount</td>
							<td class="tdFieldInput">
								<input class="inputNumeric" type="text" readonly="readonly" id="discount" name="discount" title="Purchase discount." maxlength="20" value="<%=obj.getDiscountToString() %>" />
							</td>
							<td class="tdErrMsg">
							</td>
							<td class="tdFieldName">Quotation Item</td>
							<td class="tdFieldInput">
								<input class="inputText" readonly="readonly" title="Quotation item of this purchase." type="text" value="<%=CacheUtil.getQuotationItemName(obj.getIdQuotationItem()) %>"  maxlength="255" />							
							</td>
							<td class="tdErrMsg">
							</td>
						</tr>

					</table>
				</td>
			</tr>
		</table>
	</form>
	<%
	
		String urlPurchaseItemList = "purchaseItemList.jsp?embedded=true&isView=1&idPurchase=" + obj.getId();
	%>
		<jsp:include page='<%=urlPurchaseItemList%>'></jsp:include>
	</div>
</body>
</html>